package com.scfire.alipay

import grails.transaction.Transactional

import com.scfire.weixin.WeiXinConstants

@Transactional
class AlipayService {

	def weiXinService
    def pay(String total_fee , String projectid , String memberid , boolean checked , float donate_fee , float operate_fee,String subprojectid){
		Map<String, String> map = new HashMap<String, String>();
		map.put("service", "alipay.wap.create.direct.pay.by.user");
		map.put("partner", AlipayConfig.partner);
		map.put("seller_id", AlipayConfig.seller_id);
		map.put("_input_charset", AlipayConfig.input_charset);
		//支付类型
		map.put("payment_type", "1");
		//必填，不能修改
		//服务器异步通知页面路径
		map.put("notify_url", AlipayConfig.notify_url+"?projectid="+projectid+"&memberid="+memberid+"&checked="+checked+"&donate_fee="+donate_fee+"&operate_fee="+operate_fee+"&subprojectid="+subprojectid);
		//页面跳转同步通知页面路径
		map.put("return_url", AlipayConfig.return_url+"?projectid="+projectid+"&memberid="+memberid+"&donate_fee="+donate_fee);
		//卖家支付宝帐户
		map.put("seller_email", AlipayConfig.seller_email);
		//商户订单号
		println weiXinService.mch_billno()+"-----------"
		map.put("out_trade_no", weiXinService.mch_billno());
		//订单名称
		map.put("subject", "火堆公益");
		//付款金额
		map.put("total_fee", total_fee);
		//订单描述
		map.put("body", "火堆公益，为公益捐献一份爱心！");
		//商品展示地址
		map.put("show_url", AlipayConfig.show_url);
		//防钓鱼时间戳
		map.put("anti_phishing_key", AlipaySubmit.query_timestamp());
		//客户端的IP地址
		map.put("exter_invoke_ip", WeiXinConstants.spbill_create_ip);
		//建立请求
		String sHtmlText = AlipaySubmit.buildRequest(map,"get","确认");
		return sHtmlText
	}
}
